package org.fengling.readingplatform.novel.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.fengling.readingplatform.model.vo.site.IndexVo;
import org.fengling.readingplatform.model.entity.novel.Category;
import org.fengling.readingplatform.model.vo.common.Result;
import org.fengling.readingplatform.model.vo.common.ResultCodeEnum;
import org.fengling.readingplatform.novel.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "首页接口管理")
@RestController
@RequestMapping(value="/api/novel/index")
public class IndexController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping
    public Result<IndexVo> index(){
        //1, 所有一级分类
        List<Category> categoryList = categoryService.selectOneCategory();

        //2. 根据特定方法获取前10本书

        //3. 封装数据到vo对象里面
        IndexVo indexVo = new IndexVo();
        indexVo.setCategoryList(categoryList);
        return Result.build(indexVo, ResultCodeEnum.SUCCESS);
    }
}
